package com.zqxq.lottery.cms.controller;

import com.zqxq.common.constant.Result;
import com.zqxq.lottery.cms.feign.LotteryServerFeignClient;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@Api(value = "代理商管理",tags = "代理商管理")
@RestController
@Slf4j
@RequestMapping(value = "/user/agent", produces = "application/json")
public class UserAgentController {

    @Autowired
    private LotteryServerFeignClient lotteryServerFeignClient;

    @ApiOperation("添加代理商")
    @PostMapping("/addUserAgent")
    public Result addUserAgent(String mobile,String agentId){
        return lotteryServerFeignClient.addUserAgent(mobile,agentId);
    }
    @ApiOperation("删除代理商")
    @PostMapping("/deleteUserAgent")
    public Result deleteUserAgent(Long userId,Integer status){
        return lotteryServerFeignClient.deleteUserAgent(userId,status);
    }

    @ApiOperation("获取代理商数据")
    @PostMapping("/getUserAgentData")
    public Result getUserAgentData(@ApiParam(value = "开始时间",required = false) String startTime,
                                   @ApiParam(value = "结束时间",required = false) String endTime,
                                   @ApiParam(value = "代理商id",required = false) String agentId,
                                   @ApiParam(value = "日期类型1:月 2：日",required = false) @RequestParam(defaultValue = "1") Integer timeType,
                                   @ApiParam(value = "页码",required = true) @RequestParam(defaultValue = "1") Integer pageNo,
                                   @ApiParam(value = "每页条数",required = true) @RequestParam(defaultValue = "10") Integer pageSize){
        log.info("获取代理商数据,参数 startTime={},endTime={},agentId={},timeType={}",startTime,endTime,agentId,timeType);
        return lotteryServerFeignClient.getUserAgentData(startTime,endTime,agentId,timeType,pageNo,pageSize);

    }
}
